package br.com.news.database.services;

import javax.inject.Inject;
import javax.inject.Named;

import br.com.news.database.daos.interfaces.IAlternativaEnqueteDao;
import br.com.news.database.entities.AlternativaEnqueteEntity;
import br.com.news.database.entities.keys.AlternativaEnqueteKeyEntity;
import br.com.news.database.exception.DataBaseException;
import br.com.news.database.utils.GenericServiceWithKey;
import br.com.news.database.utils.interfaces.IGenericDao;
import br.com.news.utils.database.beans.AlternativaEnqueteBean;
import br.com.news.utils.database.beans.keys.AlternativaEnqueteKeyBean;
import br.com.news.utils.database.exception.DataBaseServiceException;
import br.com.news.utils.database.interfaces.IAlternativaEnqueteServiceDb;

@Named
public class AlternativaEnqueteServiceDb
		extends
		GenericServiceWithKey<AlternativaEnqueteBean, AlternativaEnqueteEntity, AlternativaEnqueteKeyBean, AlternativaEnqueteKeyEntity>
		implements IAlternativaEnqueteServiceDb {

	@Inject
	private IAlternativaEnqueteDao alternativaEnqueteDao;

	@Override
	protected IGenericDao<AlternativaEnqueteEntity, AlternativaEnqueteKeyEntity> getConcreteDao() {
		return this.alternativaEnqueteDao;
	}

	@Override
	public void save(AlternativaEnqueteBean alternativaEnquete)
			throws DataBaseServiceException { 
		try {
			alternativaEnqueteDao.save(parserBean(alternativaEnquete));
		} catch (DataBaseException e) {
			throw new DataBaseServiceException("Erro ao tentar salvar a entidade",e);
		}
	}

}
